using System;
using SQLServices.Runners;
using SQLServices.TransMgr;

namespace SQLRunnerLib.TransMgr
{
    public static class FactoryTransMgr
    {
        public static ITransManager GetInstance(ConnectionMgrType type, IRunner runner)
        {
            if (!Enum.IsDefined(typeof(ConnectionMgrType), type))
                throw new ApplicationException("Invalid type for ConnectionMgrType was passed");
            string className = Enum.GetName(typeof(ConnectionMgrType), type);
            className = typeof(FactoryTransMgr).Namespace + "." + className;
            return (ITransManager) Activator.CreateInstance(Type.GetType(className), runner);
        }
    }
}
